package com.tour.tour.controller;

import com.tour.tour.common.Response;
import com.tour.tour.exception.UserStatusException;
import com.tour.tour.service.impl.FileServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import java.io.IOException;

/**
 * @author 76004
 * @apiNote
 * @date 2023/5/23 20:28
 */
@RestController
@RequestMapping("/file")
@CrossOrigin
public class FileController {
    @Autowired
    private FileServiceImpl fileService;

    @PostMapping("/uploadAvatar")
    public Response<String> uploadAvatar(MultipartFile multipartFile, HttpServletRequest httpServletRequest) throws UserStatusException, IOException {
        return fileService.uploadAvatar(multipartFile, httpServletRequest);
    }
}
